package com.css.modules.lawRepo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.css.common.utils.PageUtils;
import com.css.common.utils.Query;
import com.css.modules.lawRepo.dao.LawRepoLegalCategoryTDao;
import com.css.modules.lawRepo.entity.LawRepoLegalCategoryTEntity;
import com.css.modules.lawRepo.service.LawRepoLegalCategoryTService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;


@Service
public class LawRepoLegalCategoryTServiceImpl extends ServiceImpl<LawRepoLegalCategoryTDao, LawRepoLegalCategoryTEntity> implements LawRepoLegalCategoryTService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LawRepoLegalCategoryTEntity> page = this.page(
                new Query<LawRepoLegalCategoryTEntity>().getPage(params),
                new QueryWrapper<LawRepoLegalCategoryTEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public LawRepoLegalCategoryTEntity findByKeywords(String keywords) {
        LawRepoLegalCategoryTEntity legalCategoryEntity= this.baseMapper.findByKeywords(keywords);
        return legalCategoryEntity;
    }

    @Override
    public void  insert(LawRepoLegalCategoryTEntity legalCategoryEntity) {
      /*  String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        legalCategoryEntity.setId(id);*/
        legalCategoryEntity.setDelFlag("2");
        legalCategoryEntity.setCreatorId(UUID.randomUUID().toString().replaceAll("-", ""));
        this.save(legalCategoryEntity);
    }

    @Override
    public void commonUpdateDelFlagBatch(String delFlag, Map<String, Object> mapIds){
        Map<String, Object> map = new HashMap<>(2);
        map.put("list", mapIds.get("ids"));
        map.put("delFlag", delFlag);
        baseMapper.commonUpdateDelFlagBatch(map);
    }

    @Override
    public List<LawRepoLegalCategoryTEntity> findAllChildren(String uuid) {
        return baseMapper.findAllChildren(uuid);
    }

    @Override
    public List<LawRepoLegalCategoryTEntity> findChildrenByName(String name) {
        return baseMapper.findChildrenByName(name);
    }


}
